package at.fhj.pse.pageobjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;


public class AddIntervalsPage
{
	private WebDriver driver;

	/*
	 * Constructor
	 */
	public AddIntervalsPage(WebDriver driver2) {
		this.driver = driver2;
	}


	/*
	 * Input field: username:String
	 */
	private String username;
	public String getUsername()
	{
		return username;
	}
	public void setUsername(String username)
	{
		this.username = username;
	}


	/*
	 * Input field: password:String
	 */
	private String password;
	public String getPassword()
	{
		return password;
	}
	public void setPassword(String password)
	{
		this.password = password;
	}

	/*
	 * Input field: date1:Date
	 */
	private String date1;
	public String getDate1() {
		
		return date1;
	}
	public void setDate1(String string) {
		
		this.date1 = string;
	}


	/*
	 * Input field: date2:Date
	 */
	private String date2;
	public String getDate2() {
		
		return date2;
	}
	public void setDate2(String date2) {
		
		this.date2 = date2;
	}
	
	
	/*
	 * Input field: comment:String
	 */
	private String comment;
	public String getComment() {
		
		return comment;
	}
	public void setComment(String comment) {
		
		this.comment = comment;
	}
	
	
	/*
	 * Action: addTimeInterval
	 */
	public ShowIntervalsPage addTimeInterval()
	{
		//driver.get(baseUrl);
		
		driver.findElement(By.xpath("//div[@id='j_idt20:j_idt21']/ul/li[5]/a/span[2]")).click();
		driver.findElement(By.id("addTimeIntervalForm:datetime1_input")).click();
		driver.findElement(By.id("addTimeIntervalForm:datetime1_input")).clear();
		driver.findElement(By.id("addTimeIntervalForm:datetime1_input")).sendKeys(getDate1());
		driver.findElement(By.xpath("//table[@id='intervalAdd_table']/tbody/tr[2]/td")).click();
		driver.findElement(By.id("addTimeIntervalForm:datetime2_input")).click();
		driver.findElement(By.id("addTimeIntervalForm:datetime2_input")).clear();
		driver.findElement(By.id("addTimeIntervalForm:datetime2_input")).sendKeys(getDate2());
		driver.findElement(By.xpath("//table[@id='intervalAdd_table']/tbody/tr[3]/td")).click();
		driver.findElement(By.xpath("//div[@id='addTimeIntervalForm:activity']/div[3]/ul/li")).click();
		driver.findElement(By.id("addTimeIntervalForm:comment")).clear();
		driver.findElement(By.id("addTimeIntervalForm:comment")).sendKeys(getComment());
		driver.findElement(By.id("addTimeIntervalForm:submitTimeInterval")).click();
		
		return new ShowIntervalsPage(driver);
		
		
		//driver.findElement(By.xpath("//tbody[@id='showIntervalsForm:intervalsTable_data']/tr/td[2]")).click();
		//driver.findElement(By.name("logoutForm:j_idt13")).click();
		
	}

}
